package com.example.toast;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    Button btn_1;
    Button btn_2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btn_1=findViewById(R.id.button_1);
        btn_2=findViewById(R.id.button_2);

        Toast.makeText(MainActivity.this,"这是一条短的toast",Toast.LENGTH_SHORT).show();

        btn_1.setOnClickListener((v)->{
            Toast.makeText(MainActivity.this,"这是一条长的toast",Toast.LENGTH_LONG).show();
        });

    }
}